/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package InterfazUsuario;

import Control.EntityMan;
import Control.MarcaJpaController;
import Control.exceptions.NonexistentEntityException;
import Control.exceptions.PreexistingEntityException;
import Entidades.Marca;
import com.l2fprod.gui.plaf.skin.SkinLookAndFeel;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author luksCastro
 */
public class NewJFrame extends javax.swing.JFrame {
    
    private DefaultTableModel dtm;
    private boolean esNuevo = true;
    private boolean esCambio = false;  
    String idMarca;
    String nombreMarca;
    String descMarca;
    //--------------------------------------------
        public NewJFrame() {
        initComponents();
        dtm = (DefaultTableModel) jTablaMarca.getModel();
        jTablaMarca.setModel(dtm);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        SELHibernatePUEntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("SELHibernatePU").createEntityManager();
        marcaQuery = java.beans.Beans.isDesignTime() ? null : SELHibernatePUEntityManager.createQuery("SELECT m FROM Marca m");
        marcaList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : marcaQuery.getResultList();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTablaMarca = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jBtnGuardar = new javax.swing.JButton();
        jBtnNuevo = new javax.swing.JButton();
        jTxtMarca = new javax.swing.JTextField();
        jBtnEliminar = new javax.swing.JButton();
        jBtnCancelar = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTxtAreaDesc = new javax.swing.JTextArea();
        jBtnSiguiente = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Carga de marcas y modelos");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tabla marcas"));

        jTablaMarca.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "IdMarca", "Marca", "Descripcion"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTablaMarca.setColumnSelectionAllowed(true);
        jTablaMarca.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTablaMarcaMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTablaMarca);
        jTablaMarca.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Acciones"));

        jBtnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/png/16x16/accept.png"))); // NOI18N
        jBtnGuardar.setText("Guardar");
        jBtnGuardar.setEnabled(false);
        jBtnGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnGuardarActionPerformed(evt);
            }
        });

        jBtnNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/png/16x16/add.png"))); // NOI18N
        jBtnNuevo.setText("Nueva marca");
        jBtnNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnNuevoActionPerformed(evt);
            }
        });

        jTxtMarca.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jTxtMarca.setEnabled(false);
        jTxtMarca.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jTxtMarcaPropertyChange(evt);
            }
        });

        jBtnEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/png/16x16/delete.png"))); // NOI18N
        jBtnEliminar.setText("Eliminar");
        jBtnEliminar.setEnabled(false);
        jBtnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnEliminarActionPerformed(evt);
            }
        });

        jBtnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/png/16x16/block.png"))); // NOI18N
        jBtnCancelar.setText("Cancelar");
        jBtnCancelar.setEnabled(false);

        jTxtAreaDesc.setColumns(20);
        jTxtAreaDesc.setRows(5);
        jTxtAreaDesc.setEnabled(false);
        jScrollPane2.setViewportView(jTxtAreaDesc);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jBtnEliminar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBtnGuardar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBtnCancelar))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane2)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(jBtnNuevo)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jTxtMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jBtnNuevo)
                    .addComponent(jTxtMarca, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBtnEliminar)
                    .addComponent(jBtnGuardar)
                    .addComponent(jBtnCancelar))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jBtnSiguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/png/16x16/next.png"))); // NOI18N
        jBtnSiguiente.setText("Siguiente");
        jBtnSiguiente.setEnabled(false);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBtnSiguiente))
                .addContainerGap(68, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jBtnSiguiente)))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Marca", jPanel3);

        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Marca: marca");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(85, 85, 85)
                .addComponent(jLabel1)
                .addContainerGap(151, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(334, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(188, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Modelo", jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        //----------------------------------------------------------------------
        cargarTablaMarcas();
    }//GEN-LAST:event_formWindowOpened
    //----------------------------------------------------------------------------------
    //----------------------------------------------------------------------------------
    private void cargarTablaMarcas(){
        MarcaJpaController mjc = new MarcaJpaController(null, EntityMan.getInstance());        
        try {
            //----- borro la tabla 1ro antes de cargarla de nuevo-----
            for (int i = dtm.getRowCount()-1; i >= 0; i--) {
                dtm.removeRow(i);                
            }
            jTablaMarca.removeAll();
            //--------------------------------------------------------
            List<Marca> resultMarca = mjc.findMarcaEntities();
            for (int i = 0; i<resultMarca.size(); i++) {
                Integer idM= resultMarca.get(i).getIdMarca();
                String id = String.valueOf(idM) ;
                String nomMarca=resultMarca.get(i).getNombreMarca();
                String descrip=resultMarca.get(i).getDescripcion();
                String fila[]={id,nomMarca,descrip};
                dtm.addRow(fila);                
            }        
            setOcultarColumnasJTable(jTablaMarca, new int[]{0,2});            
            jBtnGuardar.setEnabled(false);
            jBtnEliminar.setEnabled(false);
        }catch (Exception e) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE,null,e);
        }
    }
    //----------------------------------------------------------------------------------
    private void jTablaMarcaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTablaMarcaMouseClicked
        // cuando se selecciones una fila, se copia el contenido en el textbox, 
        // y se activa el boton de "guardar"
        int pos = jTablaMarca.getSelectedRow();        
        idMarca = dtm.getValueAt(pos, 0).toString();
        nombreMarca = dtm.getValueAt(pos,1).toString();
        descMarca = dtm.getValueAt(pos, 2).toString();        
        jTxtMarca.setText(nombreMarca);
        jTxtAreaDesc.setText(descMarca);
        //jBtnGuardar.setEnabled(true);
        jBtnEliminar.setEnabled(true);
        jTxtAreaDesc.setEnabled(true);        
        jTxtMarca.setEnabled(true);
        esNuevo = false;
    }//GEN-LAST:event_jTablaMarcaMouseClicked

    private void jBtnNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnNuevoActionPerformed
        // cuando se hace click en el boton "nueva marca"
        // se limpia el textbox, el label del boton cambia "Guargar" 
        jTxtMarca.setText("");
        jTxtAreaDesc.setText("");
        jTxtMarca.setEnabled(true);
        jTxtAreaDesc.setEnabled(true);
        esNuevo = true;        
    }//GEN-LAST:event_jBtnNuevoActionPerformed

    private void jTxtMarcaPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jTxtMarcaPropertyChange
        // si el jtxtBoxMarca esta vacio, se debe desactivar el boton jBtnModificar
        if ("".equals(jTxtMarca.getText()) && esCambio==false) {
            jBtnGuardar.setEnabled(false);
            jBtnEliminar.setEnabled(false);
            esCambio=true;
        } else {
            jBtnGuardar.setEnabled(true);
            jBtnEliminar.setEnabled(true);
        }

    }//GEN-LAST:event_jTxtMarcaPropertyChange

    private void jBtnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnEliminarActionPerformed
        try {
            // TODO add your handling code here:
            MarcaJpaController mjc = new MarcaJpaController(null, EntityMan.getInstance());        
            int intIdMartca =Integer.parseInt(idMarca);
            int seleccion = JOptionPane.showOptionDialog(
            null,
            "Deseas eliminar la marca", 
            "ATENCION",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,    // null para icono por defecto.
            new Object[] { "Aceptar", "Cancelar" },   // null para YES, NO y CANCEL
            "Aceptar");

            if (seleccion == 0)
            {
                if (mjc.destroy(intIdMartca)) {
                    JOptionPane.showMessageDialog(null, "Los datos se han Eliminado correctamente");
                    // hacer qnse recargue la tabla marcas
                    cargarTablaMarcas();
                    jBtnEliminar.setEnabled(false);
                    //-- borrar los campos ---
                    jTxtMarca.setText("");
                    jTxtAreaDesc.setText("");
                    jTxtMarca.setEnabled(false);
                    jTxtAreaDesc.setEnabled(false);
                    esNuevo = true;                
                } else {
                    JOptionPane.showMessageDialog(null, "Error durante el intento de eliminar la marca");
                }               
            }else{
                System.out.println("Se cancelo la operacion");
            }
        } catch (NonexistentEntityException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jBtnEliminarActionPerformed
//---------------------------------------------------------------------------------------------
    private void jBtnGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnGuardarActionPerformed
        
        if (!"".equals(jTxtMarca.getText()) && !"".equals(jTxtAreaDesc.getText()) && esNuevo == true) {
            Marca m = new Marca();
            MarcaJpaController ControladorMarca = new MarcaJpaController(null, EntityMan.getInstance());
            String nombMarca = jTxtMarca.getText();
            String descMarca = jTxtAreaDesc.getText();
            m.setNombreMarca(nombMarca);
            m.setDescripcion(descMarca);
            try {
                ControladorMarca.create(m);                
                JOptionPane.showMessageDialog(null, "Los datos se han guardados correctamente");
                // borramos los campos 
                jTxtMarca.setText("");
                jTxtAreaDesc.setText("");
                jBtnGuardar.setEnabled(false);
                jTxtAreaDesc.setEnabled(false);
                jTxtMarca.setEnabled(false);              
                // recupero los datos (id) de la nueva fila
                Marca m1 = ControladorMarca.findMarca(nombMarca);                
                String id = String.valueOf(m1.getIdMarca().intValue()); 
                String nomMarca=m.getNombreMarca();
                String descrip=m.getDescripcion();              
                String fila[]={id,nomMarca,descrip};
                dtm.addRow(fila);                                
                setOcultarColumnasJTable(jTablaMarca, new int[]{0,2});
                jBtnGuardar.setEnabled(false);
            } catch (Exception e) {
                Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE,null,e);
                JOptionPane.showMessageDialog(null, "ERROR en la proceso de guardar los datos");
            }
            
        } else {
            // si no es nuevo entonces es una modificacion
        }
    }//GEN-LAST:event_jBtnGuardarActionPerformed

    //--------------------------------------------------------------------------
    private void setOcultarColumnasJTable(JTable tbl, int columna[])
    {
        for(int i=0;i<columna.length;i++)
        {
             tbl.getColumnModel().getColumn(columna[i]).setMaxWidth(0);
             tbl.getColumnModel().getColumn(columna[i]).setMinWidth(0);
             tbl.getTableHeader().getColumnModel().getColumn(columna[i]).setMaxWidth(0);
             tbl.getTableHeader().getColumnModel().getColumn(columna[i]).setMinWidth(0);
        }
    }
    //--------------------------------------------------------------------------
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        try {            
            JFrame.setDefaultLookAndFeelDecorated(true);
            SkinLookAndFeel.setSkin( SkinLookAndFeel.loadThemePack("temas/gfxOasisthemepack.zip"));
            UIManager.setLookAndFeel("com.l2fprod.gui.plaf.skin.SkinLookAndFeel");
            new NewJFrame().setVisible(true);            
        } catch (Exception e) {               
            JOptionPane.showMessageDialog(null, e);
        }
            
        
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.persistence.EntityManager SELHibernatePUEntityManager;
    private javax.swing.JButton jBtnCancelar;
    private javax.swing.JButton jBtnEliminar;
    private javax.swing.JButton jBtnGuardar;
    private javax.swing.JButton jBtnNuevo;
    private javax.swing.JButton jBtnSiguiente;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTablaMarca;
    private javax.swing.JTextArea jTxtAreaDesc;
    private javax.swing.JTextField jTxtMarca;
    private java.util.List<Entidades.Marca> marcaList;
    private javax.persistence.Query marcaQuery;
    // End of variables declaration//GEN-END:variables
}
